package com.sf.dlb.mapper.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by tanjing on 2019/5/13.
 */
@Mapper
public interface UserDlbRecodMapper {

    /**
     * 查询用户收益-source
     */
    @Select("SELECT SUM(cast(a.dlb_number as DECIMAL(18,3))) FROM user_dlb_record a WHERE a.user_id=#{userId} AND a.source=#{source} AND a.del_flag=#{delFlag}")
    Double queryUserEarningsAndSouce(@Param("userId") String userId,@Param("source")String source,@Param("delFlag")String delFlag);

    /**
     * 查询用户收益-source
     */
    @Select("<script>" +
            "SELECT SUM(cast(a.dlb_number as DECIMAL(18,3))) FROM user_dlb_record a WHERE a.user_id=#{userId} AND a.del_flag=#{delFlag} AND a.source in" +
            "   <foreach  item='item' index='index' collection='sourceList' open='(' separator=',' close=')'>" +
            "       #{item}" +
            "   </foreach>" +
            "</script>")
    Double queryUserEarningsAndSouces(@Param("userId") String userId, @Param("sourceList")List sourceList, @Param("delFlag")String delFlag);

}
